package com.dave.gd.common.util;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import com.dave.gd.common.exception.RtManagerException;

public class EntityInsFactory {
    
    private static ConcurrentMap<String, Object> map = new ConcurrentHashMap<String, Object>();
    
    private EntityInsFactory() {
        
    }
    
    public static Object getInstance(Class<?> clazz) {
        try {
            Object entity = null;
            if (!map.containsKey(clazz.getName())) {
                entity = clazz.newInstance();
                map.put(clazz.getName(), entity);
            }
            return map.get(clazz.getName());
        } catch (Exception e) {
            throw new RtManagerException("初始化失败", e);
        }
    }
}
